<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.jdo.Query" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="guestbook.Greeting" %>
<%@ page import="guestbook.Box" %>
<%@ page import="guestbook.PMF" %>
<%@ page import="guestbook.FDT_data" %>
<%@ page import="guestbook.RSS_data" %>
<%@ page import="guestbook.PK_data" %>

<html>
<head>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
</head>

<body>

<%
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user != null) {
		%>
		<p>Hello, <%= user.getNickname() %>! (You can
		<a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>.)</p>
		<%
	} else {
		%>
		<p>Hello!
		<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a>
		to include your name with greetings you post.</p>
		<%
			}
		%>

	<%
	PersistenceManager pm = PMF.get().getPersistenceManager();
	String query = "select from " + Greeting.class.getName() + " order by date desc range 0,5";
	List<Greeting> greetings = (List<Greeting>) pm.newQuery(query).execute();
	if (greetings.isEmpty()) {
	%>

	<p>The guestbook has no messages.</p>

	<%
	} else {
		for (Greeting g : greetings) {
			if (g.getAuthor() == null) {
	%>

				<p>An anonymous person wrote:</p>
			<%
			} else {
			%>
				<p><b><%= g.getAuthor().getNickname() %></b> wrote:</p>
			<%
			}
			%>
			<blockquote><%= g.getContent() %></blockquote>
			<%
		}
	}
		%>

<br>
<p>Trivial dump of the PK_data...</p>
<br>

<%
	query = "select from " + PK_data.class.getName();// + " order by lcd1 desc range 0,5";
	List<PK_data> pk_datas = (List<PK_data>) pm.newQuery(query).execute();
	if (pk_datas.isEmpty()) {
%>

<p>The PK_data is empty.</p>

<%
	} else {
		for (PK_data p : pk_datas) {
%>
<%= p.get_name() %>: <%= p.get_free() %>. 

<%
		}
	}
%>

<br>
<p>Trivial dump of the FDT_data...</p>
<br>

<%
	query = "select from " + FDT_data.class.getName();// + " order by lcd1 desc range 0,5";
	List<FDT_data> fdt_datas = (List<FDT_data>) pm.newQuery(query).execute();
	if (fdt_datas.isEmpty()) {
%>

<p>The FDT_data is empty.</p>

<%
	} else {
		for (FDT_data f : fdt_datas) {
%>
<%= f.get_road_name() %> :: [<%= f.get_flow() %> - <%= f.get_speed() %>]. 

<%
		}
	}
%>

<br>
<p>Trivial dump of the RSS_data...</p>
<br>

<%
	query = "select from " + RSS_data.class.getName();// + " order by lcd1 desc range 0,5";
	List<RSS_data> rss_datas = (List<RSS_data>) pm.newQuery(query).execute();
	if (rss_datas.isEmpty()) {
%>

<p>The RSS_data is empty.</p>

<%
	} else {
		for (RSS_data r : rss_datas) {
%>
<%= r.get_title() %> :: [<%= r.get_link() %>]. 


<%
		}
	}
%>

	<%
	pm.close();
	%>

	<form action="/sign" method="post">
		<div><textarea name="content" rows="3" cols="60"></textarea></div>
		<div><input type="submit" value="Post Greeting" /></div>
	</form>
	<br>
	<form action="/box" method="post">
		<div><textarea name="content" rows="3" cols="60"></textarea></div>
		<div><input type="submit" value="Save a Box" /></div>
	</form>
	<br>
	<form action="/fdt" method="post">
		<div><input type="submit" value="Process FDT dataset" /></div>
	</form>
	<br>
	<br>
	<form action="/pk" method="post">
		<div><input type="submit" value="Process PK dataset" /></div>
	</form>
	<br>
	<br>
	<form action="/rss" method="post">
		<div><textarea name="content" rows="1" cols="60"></textarea></div>
		<div><input type="submit" value="Process RSS dataset" /></div>
	</form>
	<br>
	<br>
	<form action="/deleterss" method="post">
		<div><input type="submit" value="Drop RSS dataset" /></div>
	</form>
<br><br>
Tutti i canali (oggi): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=today&refProgetto=2
<br>
Tutti i canali (domani): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=tomorrow&refProgetto=2
<br><br>
Mostre (oggi): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=today&refProgetto=2&refCanale=73
<br>
Mostre (domani): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=tomorrow&refProgetto=2&refCanale=73
 <br><br> 
Musica (oggi): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=today&refProgetto=2&refCanale=74
<br>Musica (domani): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=tomorrow&refProgetto=2&refCanale=74
 <br><br> 
Cinema (oggi): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=today&refProgetto=2&refCanale=75
<br>Cinema (domani): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=tomorrow&refProgetto=2&refCanale=75
 <br><br>
Teatro e Danza (oggi): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=today&refProgetto=2&refCanale=76
<br>Teatro e Danza (domani): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=tomorrow&refProgetto=2&refCanale=76
 <br><br>
Libri e Biblioteche (oggi): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=today&refProgetto=2&refCanale=77
<br>Libri e Biblioteche (domani): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=tomorrow&refProgetto=2&refCanale=77
 <br><br>
Incontri e Conferenze (oggi): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=today&refProgetto=2&refCanale=78
<br>Incontri e Conferenze (domani): http://www.torinocultura.it/servizionline/memento/rss.php?context=rss&action=rss&currDate=tomorrow&refProgetto=2&refCanale=78
	<br><br>
	<img src="/imgs/java_logo.jpg" alt="Java Logo">
	<br>
	<img src="/imgs/appengine_logo.gif" alt="AppEngine Logo">
	<br>
	<br> 


  </body>
</html>
